<template>
  <div>
    <el-table :data="tableData" style="width: 100%">
      <el-table-column label="类型ID">
        <!-- 作用域插槽 -->
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{
            scope.row.questions_type_id
          }}</span>
        </template>
      </el-table-column>
      <el-table-column label="类型名称">
        <template slot-scope="scope">
          {{ scope.row.questions_type_text }}
        </template>
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <!-- scope.$index 下标 -->
          <!-- scope.row  当前行的内容 -->
          <el-button size="mini" @click="handleEdit(scope.$index, scope.row)"
            >编辑</el-button
          >
          <el-popconfirm @confirm="success" @cancel="cancel" title="这是一段内容确定删除吗？">
            <el-button
              size="mini"
              type="danger"
              slot="reference"
              >删除</el-button
            >
          </el-popconfirm>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { getQuestionsType } from "@/api/exam";
export default {
  data() {
    return {
      tableData: [],
    };
  },
  created() {
    getQuestionsType().then((res) => {
      if (res.code === 1) {
        this.tableData = res.data;
      }
    });
  },
  methods: {
    handleEdit(index, row) {
      console.log(index, row);
    },
    success() {
      this.$message.success("删除成功")
    },
    cancel() {
      this.$message.info("取消删除")
    }
  },
};
</script>

<style>
</style>